preexperiment_date <- "07 June 2023 11 49AM/All"
postexperiment_date <- "07 June 2023 04 42PM/All"
##--- last fish run in trial ---##
experiment_date <- "07 June 2023 01 25PM/Oxygen"
experiment_date2 <- "07 June 2023 01 25PM/All"
firesting <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19)
Cycle_1 <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE)
Cycle_last <-read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_date2,"slopes/Cycle_21.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) preexperiment_date_asus <- "07 June 2023 12 05PM/All"
postexperiment_date_asus <- "07 June 2023 05 49PM/All"
##--- last fish run in trial ---##
experiment_date_asus <- "07 June 2023 02 21PM/Oxygen"
experiment_date2_asus <- "07 June 2023 02 21PM/All"
firesting_asus <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19)
Cycle_1_asus <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE)
Cycle_last_asus <-read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date2_asus,"slopes/Cycle_21.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) chamber1_dell = 0.04650
chamber2_dell = 0.04593
chamber3_dell = 0.04977
chamber4_dell = 0.04860
chamber1_asus = 0.04565
chamber2_asus = 0.04573
chamber3_asus = 0.04551
chamber4_asus = 0.04791
Date_tested="2023-06-07"
Clutch = "116"
Male = "CVLA102"
Female = "CVLA466"
Population = "Vlassof Cay"
Tank =320
salinity = 37
Date_analysed = Sys.Date() Replicate = 1
mass = 0.0006950
chamber = "ch4"
Swim = "good/good"
chamber_vol = chamber4_dell
system1 = "Dell_7440"
Notes="Is this max?"
##--- time of trail ---##
experiment_mmr_date <- "07 June 2023 12 48PM/Oxygen"
experiment_mmr_date2 <- "07 June 2023 12 48PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_4.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_5.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_6.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0001445401
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0008886788
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 6 7 8 10 12 13 14 15 16 17 18 19 22 23 24 25
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 7.52
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 35 36 37 38 124 125 129 130 133 134 138 139 142 143 147 148 152 153 157
## [20] 158
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 7.52
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 15 1 365.1533 -0.01975285 0.993 NA 7572 7827 13480.82
## 2: 16 1 395.1020 -0.02110757 0.987 NA 8112 8367 14020.82
## 3: 17 1 342.8843 -0.01675714 0.987 NA 8652 8907 14560.82
## 4: 18 1 380.9784 -0.01865367 0.993 NA 9192 9447 15100.82
## 5: 19 1 361.0886 -0.01673480 0.982 NA 9732 9987 15640.82
## 6: 21 1 420.1576 -0.01917881 0.985 NA 10812 11067 16720.82
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 13735.82 98.633 93.566 -0.01975285 -0.0006647728 -0.01908807 -0.01908807
## 2: 14275.82 98.798 93.435 -0.02110757 -0.0007010854 -0.02040649 -0.02040649
## 3: 14815.82 98.800 94.251 -0.01675714 -0.0007373979 -0.01601974 -0.01601974
## 4: 15355.82 99.095 94.310 -0.01865367 -0.0007737105 -0.01787995 -0.01787995
## 5: 15895.82 99.086 94.644 -0.01673480 -0.0008100231 -0.01592477 -0.01592477
## 6: 16975.82 99.249 94.255 -0.01917881 -0.0008826482 -0.01829616 -0.01829616
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0486 0.000695 NA 37 27 1.013253 -0.2155887
## 2: %Air sec 0.0486 0.000695 NA 37 27 1.013253 -0.2304794
## 3: %Air sec 0.0486 0.000695 NA 37 27 1.013253 -0.1809337
## 4: %Air sec 0.0486 0.000695 NA 37 27 1.013253 -0.2019437
## 5: %Air sec 0.0486 0.000695 NA 37 27 1.013253 -0.1798611
## 6: %Air sec 0.0486 0.000695 NA 37 27 1.013253 -0.2066445
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -310.1996 NA mgO2/hr/kg -310.1996
## 2: -331.6251 NA mgO2/hr/kg -331.6251
## 3: -260.3362 NA mgO2/hr/kg -260.3362
## 4: -290.5665 NA mgO2/hr/kg -290.5665
## 5: -258.7929 NA mgO2/hr/kg -258.7929
## 6: -297.3302 NA mgO2/hr/kg -297.3302
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 1 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.000695 | ch4 | Dell_7440 | 0.0486 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 298.0115 | 0.207118 | 0.989 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 6 7 8 10 12 13 14 15 16 17 18 19 22 23 24 25
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 1.57
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 23 24 28 29 30 34 35 36 40 41 42 43 151 152 153 154 155 156 167
## [20] 168
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 1.11
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 254.6849 -0.04164632 0.9964089 NA 222 282 3890.54
## 2: NA 2 254.4623 -0.04158895 0.9962406 NA 223 283 3891.54
## 3: NA 3 254.4279 -0.04158154 0.9961679 NA 221 281 3889.54
## 4: NA 4 253.9986 -0.04147271 0.9958039 NA 220 280 3888.54
## 5: NA 5 254.0077 -0.04147250 0.9959346 NA 224 284 3892.54
## ---
## 237: NA 237 193.6995 -0.02586429 0.9775365 NA 38 98 3706.54
## 238: NA 238 193.4191 -0.02578872 0.9778373 NA 37 97 3705.54
## 239: NA 239 193.0931 -0.02570039 0.9781611 NA 35 95 3703.54
## 240: NA 240 193.0548 -0.02569067 0.9782080 NA 36 96 3704.54
## 241: NA 241 193.0310 -0.02568302 0.9782699 NA 34 94 3702.54
## endtime oxy endoxy rate
## 1: 3950.54 92.603 90.233 -0.04164632
## 2: 3951.54 92.588 90.211 -0.04158895
## 3: 3949.54 92.583 90.250 -0.04158154
## 4: 3948.54 92.616 90.293 -0.04147271
## 5: 3952.54 92.605 90.184 -0.04147250
## ---
## 237: 3766.54 97.877 96.199 -0.02586429
## 238: 3765.54 97.895 96.225 -0.02578872
## 239: 3763.54 97.973 96.282 -0.02570039
## 240: 3764.54 97.910 96.283 -0.02569067
## 241: 3762.54 98.015 96.361 -0.02568302
##
## Regressions : 241 | Results : 241 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 241 adjusted rate(s):
## Rate : -0.04164632
## Adjustment : -0.0001445401
## Adjusted Rate : -0.04150178
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 241 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 240 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 254.6849 -0.04164632 0.9964089 NA 222 282 3890.54
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 3950.54 92.603 90.233 -0.04164632 -0.0001445401 -0.04150178 -0.04150178
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0486 0.000695 NA 37 27 1.013253 -0.4687386
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -674.444 NA mgO2/hr/kg -674.444
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 1 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.000695 | ch4 | Dell_7440 | 0.0486 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 298.0115 | 0.207118 | 0.989 | 674.444 | 0.4687386 | 0.9964089 | 376.4325 | 0.2616206 | Is this max? |
## Rows: 45 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 2
mass = 0.0007642
chamber = "ch3"
Swim = "good/good"
chamber_vol = chamber3_dell
system1 = "Dell_7440"
Notes="is this max?"
##--- time of trail ---##
experiment_mmr_date <- "07 June 2023 01 03PM/Oxygen"
experiment_mmr_date2 <- "07 June 2023 01 03PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_4.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_5.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_6.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.001459407
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -1.302502e-06
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 6 7 8 10 12 13 14 15 16 17 18 19 22 23 24 25
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 7.52
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 35 36 37 38 124 125 129 130 133 134 138 139 142 143 147 148 152 153 157
## [20] 158
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 7.52
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: background rates in 'by' and 'by2' differ in sign (i.e. one is +ve, one is -ve).
## Ensure this is correct. The 'linear' adjustment has been performed regardless.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 9 1 364.9942 -0.02597320 0.994 NA 4332 4587 10240.82
## 2: 16 1 455.3785 -0.02538240 0.995 NA 8112 8367 14020.82
## 3: 17 1 461.3822 -0.02485580 0.995 NA 8652 8907 14560.82
## 4: 19 1 499.1418 -0.02555041 0.998 NA 9732 9987 15640.82
## 5: 20 1 524.6944 -0.02626035 0.996 NA 10272 10527 16180.82
## 6: 21 1 524.1548 -0.02537786 0.997 NA 10812 11067 16720.82
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 10495.82 98.683 91.955 -0.02597320 8.658940e-04 -0.02683909 -0.02683909
## 2: 14275.82 99.177 92.895 -0.02538240 3.669347e-04 -0.02574933 -0.02574933
## 3: 14815.82 99.262 92.910 -0.02485580 2.956548e-04 -0.02515146 -0.02515146
## 4: 15895.82 99.239 92.804 -0.02555041 1.530950e-04 -0.02570350 -0.02570350
## 5: 16435.83 99.413 93.051 -0.02626035 8.181447e-05 -0.02634217 -0.02634217
## 6: 16975.82 99.425 93.203 -0.02537786 1.053524e-05 -0.02538840 -0.02538840
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04977 0.0007642 NA 37 27 1.013253 -0.3104296
## 2: %Air sec 0.04977 0.0007642 NA 37 27 1.013253 -0.2978251
## 3: %Air sec 0.04977 0.0007642 NA 37 27 1.013253 -0.2909099
## 4: %Air sec 0.04977 0.0007642 NA 37 27 1.013253 -0.2972950
## 5: %Air sec 0.04977 0.0007642 NA 37 27 1.013253 -0.3046820
## 6: %Air sec 0.04977 0.0007642 NA 37 27 1.013253 -0.2936504
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -406.2151 NA mgO2/hr/kg -406.2151
## 2: -389.7214 NA mgO2/hr/kg -389.7214
## 3: -380.6725 NA mgO2/hr/kg -380.6725
## 4: -389.0278 NA mgO2/hr/kg -389.0278
## 5: -398.6941 NA mgO2/hr/kg -398.6941
## 6: -384.2585 NA mgO2/hr/kg -384.2585
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 2 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.0007642 | ch3 | Dell_7440 | 0.04977 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 393.5834 | 0.3007764 | 0.996 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 6 7 8 10 12 13 14 15 16 17 18 19 22 23 24 25
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 1.57
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 69 70 74 75 79 80 84 85 89 90 94 95 96 97 98 99 101 102 104
## [20] 105
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 1.11
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 403.4878 -0.06582671 0.9800137 NA 179 239 4716.54
## 2: NA 2 403.0689 -0.06573834 0.9799354 NA 180 240 4717.54
## 3: NA 3 402.8224 -0.06568657 0.9799166 NA 178 238 4715.54
## 4: NA 4 402.1869 -0.06555262 0.9798363 NA 177 237 4714.54
## 5: NA 5 401.8894 -0.06549001 0.9798344 NA 181 241 4718.54
## ---
## 237: NA 237 215.2495 -0.02590372 0.9904673 NA 113 173 4650.54
## 238: NA 238 214.6300 -0.02577195 0.9915276 NA 117 177 4654.54
## 239: NA 239 214.4316 -0.02572949 0.9915349 NA 114 174 4651.54
## 240: NA 240 214.3627 -0.02571503 0.9915738 NA 115 175 4652.54
## 241: NA 241 214.1751 -0.02567483 0.9914778 NA 116 176 4653.54
## endtime oxy endoxy rate
## 1: 4776.54 93.020 89.029 -0.06582671
## 2: 4777.54 93.032 89.047 -0.06573834
## 3: 4775.54 93.027 89.094 -0.06568657
## 4: 4774.54 93.097 89.118 -0.06555262
## 5: 4778.54 93.026 89.003 -0.06549001
## ---
## 237: 4710.54 94.904 93.219 -0.02590372
## 238: 4714.54 94.630 93.097 -0.02577195
## 239: 4711.54 94.788 93.188 -0.02572949
## 240: 4712.54 94.717 93.150 -0.02571503
## 241: 4713.54 94.669 93.185 -0.02567483
##
## Regressions : 241 | Results : 241 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 241 adjusted rate(s):
## Rate : -0.06582671
## Adjustment : 0.001459407
## Adjusted Rate : -0.06728611
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 22 rate(s) removed, 219 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 218 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 403.4878 -0.06582671 0.9800137 NA 179 239 4716.54
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 4776.54 93.02 89.029 -0.06582671 0.001459407 -0.06728611 -0.06728611
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04977 0.0007642 NA 37 27 1.013253 -0.7782529
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1018.389 NA mgO2/hr/kg -1018.389
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 2 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.0007642 | ch3 | Dell_7440 | 0.04977 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 393.5834 | 0.3007764 | 0.996 | 1018.389 | 0.7782529 | 0.9800137 | 624.8057 | 0.4774765 | is this max? |
## Rows: 46 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 3
mass = 0.0007448
chamber = "ch2"
Swim = "good/good"
chamber_vol = chamber2_dell
system1 = "Dell_7440"
Notes=""
##--- time of trail ---##
experiment_mmr_date <- "07 June 2023 01 14PM/Oxygen"
experiment_mmr_date2 <- "07 June 2023 01 14PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_4.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_5.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_6.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.00167043
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0003707597
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 6 7 8 10 12 13 14 15 16 17 18 19 22 23 24 25
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 7.52
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 35 36 37 38 124 125 129 130 133 134 138 139 142 143 147 148 152 153 157
## [20] 158
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 7.52
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 14 1 483.7694 -0.02992542 0.997 NA 7032 7287 12940.82
## 2: 15 1 513.2929 -0.03090498 0.998 NA 7572 7827 13480.82
## 3: 18 1 521.9389 -0.02812625 0.998 NA 9192 9447 15100.82
## 4: 19 1 529.2421 -0.02761647 0.998 NA 9732 9987 15640.82
## 5: 20 1 557.9429 -0.02846351 0.997 NA 10272 10527 16180.82
## 6: 21 1 576.0549 -0.02862507 0.997 NA 10812 11067 16720.82
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 13195.82 96.625 89.071 -0.02992542 0.0008252428 -0.03075066 -0.03075066
## 2: 13735.82 96.751 88.624 -0.03090498 0.0007618213 -0.03166680 -0.03166680
## 3: 15355.82 97.086 89.987 -0.02812625 0.0005715568 -0.02869781 -0.02869781
## 4: 15895.82 97.149 90.234 -0.02761647 0.0005081353 -0.02812460 -0.02812460
## 5: 16435.83 97.206 89.939 -0.02846351 0.0004447133 -0.02890822 -0.02890822
## 6: 16975.82 97.258 90.115 -0.02862507 0.0003812924 -0.02900636 -0.02900636
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04593 0.0007448 NA 37 27 1.013253 -0.3282302
## 2: %Air sec 0.04593 0.0007448 NA 37 27 1.013253 -0.3380090
## 3: %Air sec 0.04593 0.0007448 NA 37 27 1.013253 -0.3063183
## 4: %Air sec 0.04593 0.0007448 NA 37 27 1.013253 -0.3001998
## 5: %Air sec 0.04593 0.0007448 NA 37 27 1.013253 -0.3085642
## 6: %Air sec 0.04593 0.0007448 NA 37 27 1.013253 -0.3096117
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -440.6958 NA mgO2/hr/kg -440.6958
## 2: -453.8252 NA mgO2/hr/kg -453.8252
## 3: -411.2759 NA mgO2/hr/kg -411.2759
## 4: -403.0610 NA mgO2/hr/kg -403.0610
## 5: -414.2913 NA mgO2/hr/kg -414.2913
## 6: -415.6978 NA mgO2/hr/kg -415.6978
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 3 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.0007448 | ch2 | Dell_7440 | 0.04593 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 427.1572 | 0.3181467 | 0.9974 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 6 7 8 10 12 13 14 15 16 17 18 19 22 23 24 25
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 1.57
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations in column: dTIME
## [1] 17 18 19 20 21 22 24 25 26 122 123 184 185
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 1.21
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 487.8097 -0.07417183 0.9899965 NA 76 136 5316.54
## 2: NA 2 487.4459 -0.07410528 0.9897867 NA 75 135 5315.54
## 3: NA 3 487.1651 -0.07405007 0.9896851 NA 77 137 5317.54
## 4: NA 4 486.9731 -0.07401843 0.9894984 NA 74 134 5314.54
## 5: NA 5 486.7246 -0.07397309 0.9893839 NA 73 133 5313.54
## ---
## 237: NA 237 219.1469 -0.02489656 0.9727045 NA 237 297 5477.54
## 238: NA 238 218.5219 -0.02478271 0.9717294 NA 238 298 5478.54
## 239: NA 239 217.9485 -0.02467821 0.9707559 NA 239 299 5479.54
## 240: NA 240 215.9301 -0.02431163 0.9682101 NA 240 300 5480.54
## 241: NA 241 213.9162 -0.02394590 0.9652359 NA 241 301 5481.54
## endtime oxy endoxy rate
## 1: 5376.54 93.316 89.245 -0.07417183
## 2: 5375.54 93.274 89.320 -0.07410528
## 3: 5377.54 93.390 89.186 -0.07405007
## 4: 5374.54 93.318 89.333 -0.07401843
## 5: 5373.54 93.464 89.370 -0.07397309
## ---
## 237: 5537.54 82.746 81.404 -0.02489656
## 238: 5538.54 82.711 81.358 -0.02478271
## 239: 5539.54 82.788 81.342 -0.02467821
## 240: 5540.54 82.746 81.382 -0.02431163
## 241: 5541.54 82.727 81.378 -0.02394590
##
## Regressions : 241 | Results : 241 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 241 adjusted rate(s):
## Rate : -0.07417183
## Adjustment : 0.00167043
## Adjusted Rate : -0.07584226
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 9 rate(s) removed, 232 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 231 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 487.8097 -0.07417183 0.9899965 NA 76 136 5316.54
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 5376.54 93.316 89.245 -0.07417183 0.00167043 -0.07584226 -0.07584226
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04593 0.0007448 NA 37 27 1.013253 -0.8095345
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1086.915 NA mgO2/hr/kg -1086.915
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 3 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.0007448 | ch2 | Dell_7440 | 0.04593 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 427.1572 | 0.3181467 | 0.9974 | 1086.915 | 0.8095345 | 0.9899965 | 659.7581 | 0.4913878 |
## Rows: 47 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 4
mass = 0.0008210
chamber = "ch1"
Swim = "good/good"
chamber_vol = chamber1_dell
system1 = "Dell_7440"
Notes=""
##--- time of trail ---##
experiment_mmr_date <- "07 June 2023 01 25PM/Oxygen"
experiment_mmr_date2 <- "07 June 2023 01 25PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_4.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_5.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_6.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.002238365
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0002072821
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 6 7 8 10 12 13 14 15 16 17 18 19 22 23 24 25
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 7.52
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 35 36 37 38 124 125 129 130 133 134 138 139 142 143 147 148 152 153 157
## [20] 158
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 7.52
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 7 1 375.8990 -0.03019182 0.982 NA 3252 3507 9160.82
## 2: 8 1 372.4058 -0.02815981 0.985 NA 3792 4047 9700.82
## 3: 9 1 420.2203 -0.03133676 0.956 NA 4332 4587 10240.82
## 4: 16 1 517.2973 -0.02982783 0.993 NA 8112 8367 14020.82
## 5: 19 1 587.9504 -0.03132305 0.996 NA 9732 9987 15640.82
## 6: 21 1 626.2141 -0.03152441 0.996 NA 10812 11067 16720.82
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 9415.82 98.632 90.640 -0.03019182 0.0016113245 -0.03180314 -0.03180314
## 2: 9955.82 98.873 91.440 -0.02815981 0.0015122115 -0.02967202 -0.02967202
## 3: 10495.82 98.893 90.589 -0.03133676 0.0014130985 -0.03274986 -0.03274986
## 4: 14275.82 98.830 91.317 -0.02982783 0.0007193073 -0.03054714 -0.03054714
## 5: 15895.82 98.204 89.823 -0.03132305 0.0004219683 -0.03174501 -0.03174501
## 6: 16975.82 99.127 90.856 -0.03152441 0.0002237422 -0.03174816 -0.03174816
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0465 0.000821 NA 37 27 1.013253 -0.3436771
## 2: %Air sec 0.0465 0.000821 NA 37 27 1.013253 -0.3206474
## 3: %Air sec 0.0465 0.000821 NA 37 27 1.013253 -0.3539077
## 4: %Air sec 0.0465 0.000821 NA 37 27 1.013253 -0.3301042
## 5: %Air sec 0.0465 0.000821 NA 37 27 1.013253 -0.3430490
## 6: %Air sec 0.0465 0.000821 NA 37 27 1.013253 -0.3430829
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -418.6080 NA mgO2/hr/kg -418.6080
## 2: -390.5571 NA mgO2/hr/kg -390.5571
## 3: -431.0691 NA mgO2/hr/kg -431.0691
## 4: -402.0758 NA mgO2/hr/kg -402.0758
## 5: -417.8429 NA mgO2/hr/kg -417.8429
## 6: -417.8842 NA mgO2/hr/kg -417.8842
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 4 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.000821 | ch1 | Dell_7440 | 0.0465 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 417.496 | 0.3427642 | 0.9846 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 6 7 8 10 12 13 14 15 16 17 18 19 22 23 24 25
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 7.52
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 35 36 37 38 124 125 129 130 133 134 138 139 142 143 147 148 152 153 157
## [20] 158
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 1.13
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 526.9179 -0.07268053 0.9826264 NA 31 91 5905.54
## 2: NA 2 526.7575 -0.07265471 0.9825463 NA 30 90 5904.54
## 3: NA 3 526.4675 -0.07260312 0.9823320 NA 32 92 5906.54
## 4: NA 4 525.7163 -0.07247511 0.9818576 NA 33 93 5907.54
## 5: NA 5 525.1404 -0.07238353 0.9816317 NA 29 89 5903.54
## ---
## 237: NA 237 234.5876 -0.02435201 0.9757373 NA 228 288 6102.55
## 238: NA 238 234.4769 -0.02433158 0.9778667 NA 233 293 6107.54
## 239: NA 239 234.0956 -0.02427043 0.9770286 NA 231 291 6105.54
## 240: NA 240 233.7328 -0.02421242 0.9759999 NA 229 289 6103.54
## 241: NA 241 233.6294 -0.02419515 0.9758270 NA 230 290 6104.54
## endtime oxy endoxy rate
## 1: 5965.54 97.451 93.550 -0.07268053
## 2: 5964.54 97.539 93.562 -0.07265471
## 3: 5966.54 97.409 93.573 -0.07260312
## 4: 5967.54 97.353 93.519 -0.07247511
## 5: 5963.54 97.505 93.568 -0.07238353
## ---
## 237: 6162.55 85.954 84.569 -0.02435201
## 238: 6167.54 85.830 84.491 -0.02433158
## 239: 6165.54 85.785 84.563 -0.02427043
## 240: 6163.54 85.882 84.581 -0.02421242
## 241: 6164.54 85.777 84.557 -0.02419515
##
## Regressions : 241 | Results : 241 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 241 adjusted rate(s):
## Rate : -0.07268053
## Adjustment : 0.002238365
## Adjusted Rate : -0.07491889
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 8 rate(s) removed, 233 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 232 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 526.9179 -0.07268053 0.9826264 NA 31 91 5905.54
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 5965.54 97.451 93.55 -0.07268053 0.002238365 -0.07491889 -0.07491889
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0465 0.000821 NA 37 27 1.013253 -0.8096027
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -986.1178 NA mgO2/hr/kg -986.1178
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 4 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.000821 | ch1 | Dell_7440 | 0.0465 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 417.496 | 0.3427642 | 0.9846 | 986.1178 | 0.8096027 | 0.9826264 | 568.6218 | 0.4668385 |
## Rows: 48 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 5
mass = 0.0008458
chamber = "ch4"
Swim = "good/good"
chamber_vol = chamber4_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "07 June 2023 01 50PM/Oxygen"
experiment_mmr_date2_asus <- "07 June 2023 01 50PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_9.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_10.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_11.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.003485556
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0001461291
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.73
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 2 3 6 7 8 9 12 13 14 16 17 18 19 20 22 23 24 25 27 29
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.73
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 12 1 601.9337 -0.03440997 0.997 NA 4452 4641 14699.53
## 2: 14 1 621.0830 -0.03326571 0.996 NA 5254 5444 15777.99
## 3: 15 1 653.4754 -0.03416665 0.998 NA 5657 5846 16319.59
## 4: 19 1 744.1935 -0.03506946 0.992 NA 7263 7452 18478.37
## 5: 20 1 761.1102 -0.03496739 0.997 NA 7664 7851 19017.62
## 6: 21 1 819.1156 -0.03694919 0.998 NA 8063 8253 19558.29
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 14953.59 95.940 87.559 -0.03440997 0.0001017922 -0.03451176 -0.03451176
## 2: 16033.61 96.168 87.927 -0.03326571 -0.0003349556 -0.03293075 -0.03293075
## 3: 16573.45 95.902 87.243 -0.03416665 -0.0005537747 -0.03361287 -0.03361287
## 4: 18732.50 96.006 87.018 -0.03506946 -0.0014274464 -0.03364202 -0.03364202
## 5: 19273.33 96.140 87.037 -0.03496739 -0.0016459902 -0.03332140 -0.03332140
## 6: 19813.57 96.239 87.133 -0.03694919 -0.0018647021 -0.03508449 -0.03508449
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04791 0.0008458 NA 37 27 1.013253 -0.3842563
## 2: %Air sec 0.04791 0.0008458 NA 37 27 1.013253 -0.3666532
## 3: %Air sec 0.04791 0.0008458 NA 37 27 1.013253 -0.3742480
## 4: %Air sec 0.04791 0.0008458 NA 37 27 1.013253 -0.3745725
## 5: %Air sec 0.04791 0.0008458 NA 37 27 1.013253 -0.3710027
## 6: %Air sec 0.04791 0.0008458 NA 37 27 1.013253 -0.3906331
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -454.3111 NA mgO2/hr/kg -454.3111
## 2: -433.4987 NA mgO2/hr/kg -433.4987
## 3: -442.4781 NA mgO2/hr/kg -442.4781
## 4: -442.8618 NA mgO2/hr/kg -442.8618
## 5: -438.6412 NA mgO2/hr/kg -438.6412
## 6: -461.8504 NA mgO2/hr/kg -461.8504
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 5 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.0008458 | ch4 | Asus | 0.04791 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 448.0285 | 0.3789425 | 0.9964 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.62
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 7 8 9 10 11 12 13 14 16 17 18 19 20 22 23 24
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.41
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 583.9794 -0.07042264 0.9798419 NA 74 119 7005.24
## 2: NA 2 583.4640 -0.07034814 0.9796128 NA 75 120 7006.59
## 3: NA 3 582.7575 -0.07025028 0.9792799 NA 73 118 7003.89
## 4: NA 4 582.4025 -0.07019610 0.9791488 NA 76 121 7007.94
## 5: NA 5 581.3219 -0.07004769 0.9785381 NA 72 117 7002.54
## ---
## 175: NA 175 365.4157 -0.03969022 0.9644782 NA 175 220 7141.19
## 176: NA 176 362.5357 -0.03928880 0.9640816 NA 176 221 7142.52
## 177: NA 177 359.2240 -0.03882744 0.9641879 NA 177 222 7143.85
## 178: NA 178 355.3681 -0.03829042 0.9645972 NA 178 223 7145.19
## 179: NA 179 351.3468 -0.03773063 0.9658081 NA 179 224 7146.58
## endtime oxy endoxy rate
## 1: 7065.24 90.433 86.596 -0.07042264
## 2: 7066.59 90.419 86.550 -0.07034814
## 3: 7063.89 90.476 86.709 -0.07025028
## 4: 7067.94 90.352 86.481 -0.07019610
## 5: 7062.54 90.523 86.767 -0.07004769
## ---
## 175: 7201.19 82.080 79.651 -0.03969022
## 176: 7202.52 82.051 79.624 -0.03928880
## 177: 7203.85 82.029 79.566 -0.03882744
## 178: 7205.19 81.988 79.532 -0.03829042
## 179: 7206.58 81.951 79.467 -0.03773063
##
## Regressions : 179 | Results : 179 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 179 adjusted rate(s):
## Rate : -0.07042264
## Adjustment : 0.003485556
## Adjusted Rate : -0.0739082
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 11 rate(s) removed, 168 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 167 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 583.9794 -0.07042264 0.9798419 NA 74 119 7005.24
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 7065.24 90.433 86.596 -0.07042264 0.003485556 -0.0739082 -0.0739082
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04791 0.0008458 NA 37 27 1.013253 -0.8228988
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -972.9236 NA mgO2/hr/kg -972.9236
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 5 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.0008458 | ch4 | Asus | 0.04791 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 448.0285 | 0.3789425 | 0.9964 | 972.9236 | 0.8228988 | 0.9798419 | 524.8951 | 0.4439563 | ||
| ### Expor | ting data |
## Rows: 49 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 6
mass = 0.0007478
chamber = "ch3"
Swim = "good/good"
chamber_vol = chamber3_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "07 June 2023 01 59PM/Oxygen"
experiment_mmr_date2_asus <- "07 June 2023 01 59PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_9.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_10.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_11.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.001119849
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.00227829
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.73
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 2 3 6 7 8 9 12 13 14 16 17 18 19 20 22 23 24 25 27 29
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.73
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## Warning: adjust_rate: background rates in 'by' and 'by2' differ in sign (i.e. one is +ve, one is -ve).
## Ensure this is correct. The 'linear' adjustment has been performed regardless.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 7 1 453.9663 -0.02977957 0.994 NA 2442 2624 11997.42
## 2: 8 1 474.3045 -0.03012342 0.996 NA 2845 3027 12539.44
## 3: 14 1 585.1357 -0.03097801 0.999 NA 5254 5437 15777.99
## 4: 17 1 629.2405 -0.03062534 0.999 NA 6459 6642 17397.63
## 5: 20 1 695.1333 -0.03148289 0.998 NA 7664 7844 19017.62
## 6: 21 1 733.0438 -0.03253112 0.998 NA 8063 8246 19558.29
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 12242.54 96.464 89.079 -0.02977957 -0.001208848 -0.02857072 -0.02857072
## 2: 12784.18 96.730 89.095 -0.03012342 -0.001431971 -0.02869145 -0.02869145
## 3: 16024.19 96.236 88.681 -0.03097801 -0.002765893 -0.02821211 -0.02821211
## 4: 17643.87 96.436 88.687 -0.03062534 -0.003432862 -0.02719248 -0.02719248
## 5: 19263.89 96.225 88.695 -0.03148289 -0.004099974 -0.02738292 -0.02738292
## 6: 19804.14 96.820 88.937 -0.03253112 -0.004322533 -0.02820859 -0.02820859
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04551 0.0007478 NA 37 27 1.013253 -0.3021730
## 2: %Air sec 0.04551 0.0007478 NA 37 27 1.013253 -0.3034499
## 3: %Air sec 0.04551 0.0007478 NA 37 27 1.013253 -0.2983803
## 4: %Air sec 0.04551 0.0007478 NA 37 27 1.013253 -0.2875963
## 5: %Air sec 0.04551 0.0007478 NA 37 27 1.013253 -0.2896104
## 6: %Air sec 0.04551 0.0007478 NA 37 27 1.013253 -0.2983430
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -404.0827 NA mgO2/hr/kg -404.0827
## 2: -405.7901 NA mgO2/hr/kg -405.7901
## 3: -399.0108 NA mgO2/hr/kg -399.0108
## 4: -384.5899 NA mgO2/hr/kg -384.5899
## 5: -387.2833 NA mgO2/hr/kg -387.2833
## 6: -398.9610 NA mgO2/hr/kg -398.9610
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 6 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.0007478 | ch3 | Asus | 0.04551 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 399.0256 | 0.2983913 | 0.997 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.62
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 11 12 13 15 16 17 18 19 21 22 23
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.44
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 647.7650 -0.07381254 0.9937253 NA 43 88 7506.00
## 2: NA 2 647.5100 -0.07377782 0.9936622 NA 44 89 7507.41
## 3: NA 3 646.9787 -0.07370647 0.9935293 NA 45 90 7508.76
## 4: NA 4 645.6065 -0.07352340 0.9931057 NA 46 91 7510.12
## 5: NA 5 645.3669 -0.07349520 0.9930921 NA 42 87 7504.65
## ---
## 175: NA 175 378.4971 -0.03833449 0.9644337 NA 156 201 7658.16
## 176: NA 176 378.1625 -0.03828577 0.9627390 NA 152 197 7652.82
## 177: NA 177 375.9217 -0.03799847 0.9663688 NA 155 200 7656.82
## 178: NA 178 375.0589 -0.03788350 0.9668691 NA 153 198 7654.14
## 179: NA 179 374.0281 -0.03775094 0.9681588 NA 154 199 7655.47
## endtime oxy endoxy rate
## 1: 7566.00 93.545 89.379 -0.07381254
## 2: 7567.41 93.537 89.358 -0.07377782
## 3: 7568.76 93.453 89.272 -0.07370647
## 4: 7570.12 93.347 89.242 -0.07352340
## 5: 7564.65 93.512 89.434 -0.07349520
## ---
## 175: 7718.16 85.047 82.381 -0.03833449
## 176: 7712.82 85.625 82.759 -0.03828577
## 177: 7716.82 85.147 82.441 -0.03799847
## 178: 7714.14 85.506 82.626 -0.03788350
## 179: 7715.47 85.358 82.526 -0.03775094
##
## Regressions : 179 | Results : 179 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 179 adjusted rate(s):
## Rate : -0.07381254
## Adjustment : 0.001119849
## Adjusted Rate : -0.07493239
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 179 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 178 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time endtime
## 1: NA 1 647.765 -0.07381254 0.9937253 NA 43 88 7506 7566
## oxy endoxy rate adjustment rate.adjusted rate.input oxy.unit
## 1: 93.545 89.379 -0.07381254 0.001119849 -0.07493239 -0.07493239 %Air
## time.unit volume mass area S t P rate.abs rate.m.spec
## 1: sec 0.04551 0.0007478 NA 37 27 1.013253 -0.7925088 -1059.787
## rate.a.spec output.unit rate.output
## 1: NA mgO2/hr/kg -1059.787
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 6 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.0007478 | ch3 | Asus | 0.04551 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 399.0256 | 0.2983913 | 0.997 | 1059.787 | 0.7925088 | 0.9937253 | 660.7616 | 0.4941175 | ||
| ### Expor | ting data |
## Rows: 50 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 7
mass = 0.0008312
chamber = "ch2"
Swim = "good/good"
chamber_vol = chamber2_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "07 June 2023 02 08PM/Oxygen"
experiment_mmr_date2_asus <- "07 June 2023 02 08PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_9.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_10.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_11.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.003500823
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.01321115
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.73
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 2 3 6 7 8 9 12 13 14 16 17 18 19 20 22 23 24 25 27 29
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.73
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 1 rate(s) removed, 20 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 14 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 13 1 727.7914 -0.04135810 0.998 NA 4852 5034 15237.28
## 2: 14 1 785.5533 -0.04359444 0.992 NA 5254 5437 15777.99
## 3: 17 1 877.1957 -0.04480710 0.998 NA 6459 6642 17397.63
## 4: 18 1 914.4386 -0.04555289 0.992 NA 6861 7044 17938.20
## 5: 19 1 948.5645 -0.04606325 0.999 NA 7263 7445 18478.37
## 6: 20 1 939.0827 -0.04428429 0.998 NA 7664 7844 19017.62
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 15482.19 97.568 87.507 -0.04135810 -0.01396748 -0.02739063 -0.02739063
## 2: 16024.19 97.246 87.388 -0.04359444 -0.01460450 -0.02898994 -0.02898994
## 3: 17643.87 97.254 86.142 -0.04480710 -0.01651039 -0.02829671 -0.02829671
## 4: 18184.08 97.064 86.798 -0.04555289 -0.01714628 -0.02840660 -0.02840660
## 5: 18723.07 97.249 85.859 -0.04606325 -0.01778122 -0.02828203 -0.02828203
## 6: 19263.89 96.709 85.708 -0.04428429 -0.01841669 -0.02586760 -0.02586760
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04573 0.0008312 NA 37 27 1.013253 -0.2910924
## 2: %Air sec 0.04573 0.0008312 NA 37 27 1.013253 -0.3080890
## 3: %Air sec 0.04573 0.0008312 NA 37 27 1.013253 -0.3007217
## 4: %Air sec 0.04573 0.0008312 NA 37 27 1.013253 -0.3018896
## 5: %Air sec 0.04573 0.0008312 NA 37 27 1.013253 -0.3005657
## 6: %Air sec 0.04573 0.0008312 NA 37 27 1.013253 -0.2749065
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -350.2074 NA mgO2/hr/kg -350.2074
## 2: -370.6557 NA mgO2/hr/kg -370.6557
## 3: -361.7922 NA mgO2/hr/kg -361.7922
## 4: -363.1973 NA mgO2/hr/kg -363.1973
## 5: -361.6045 NA mgO2/hr/kg -361.6045
## 6: -330.7344 NA mgO2/hr/kg -330.7344
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 7 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.0008312 | ch2 | Asus | 0.04573 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 361.4914 | 0.3004717 | 0.9958 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.62
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 14 15 19 20 21 22 24 25
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.50
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 736.4561 -0.07998520 0.9866589 NA 23 68 7983.77
## 2: NA 2 735.6531 -0.07988577 0.9864822 NA 22 67 7982.42
## 3: NA 3 735.3144 -0.07984197 0.9864076 NA 24 69 7985.09
## 4: NA 4 732.1746 -0.07945252 0.9856148 NA 21 66 7981.06
## 5: NA 5 730.8323 -0.07928220 0.9855658 NA 25 70 7986.44
## ---
## 174: NA 174 511.9783 -0.05210427 0.9827759 NA 89 134 8072.73
## 175: NA 175 511.7749 -0.05208116 0.9828807 NA 91 136 8075.43
## 176: NA 176 511.4412 -0.05204142 0.9831056 NA 92 137 8076.79
## 177: NA 177 511.2440 -0.05201835 0.9832156 NA 93 138 8078.12
## 178: NA 178 511.1158 -0.05182291 0.9036893 NA 1 46 7954.16
## endtime oxy endoxy rate
## 1: 8043.77 97.747 93.190 -0.07998520
## 2: 8042.42 97.740 93.245 -0.07988577
## 3: 8045.09 97.701 93.147 -0.07984197
## 4: 8041.06 97.766 93.372 -0.07945252
## 5: 8046.44 97.710 93.123 -0.07928220
## ---
## 174: 8132.73 91.519 88.148 -0.05210427
## 175: 8135.43 91.438 87.877 -0.05208116
## 176: 8136.79 91.415 87.744 -0.05204142
## 177: 8138.12 91.297 87.694 -0.05201835
## 178: 8014.16 98.689 95.108 -0.05182291
##
## Regressions : 178 | Results : 178 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 178 adjusted rate(s):
## Rate : -0.0799852
## Adjustment : -0.003500823
## Adjusted Rate : -0.07648438
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 18 rate(s) removed, 160 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 159 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 736.4561 -0.0799852 0.9866589 NA 23 68 7983.77
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 8043.77 97.747 93.19 -0.0799852 -0.003500823 -0.07648438 -0.07648438
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04573 0.0008312 NA 37 27 1.013253 -0.8128335
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -977.9037 NA mgO2/hr/kg -977.9037
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 7 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.0008312 | ch2 | Asus | 0.04573 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 361.4914 | 0.3004717 | 0.9958 | 977.9037 | 0.8128335 | 0.9866589 | 616.4122 | 0.5123618 | ||
| ### Expor | ting data |
## Rows: 51 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 8
mass = 0.0006442
chamber = "ch1"
Swim = "good/good"
chamber_vol = chamber1_asus
system1 = "Asus"
Notes="is this max?"
##--- time of trail ---##
experiment_mmr_date_asus <- "07 June 2023 02 21PM/Oxygen"
experiment_mmr_date2_asus <- "07 June 2023 02 21PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_9.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_10.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_11.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.000683435
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0006313079
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.73
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 2 3 6 7 8 9 12 13 14 16 17 18 19 20 22 23 24 25 27 29
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.73
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 1 rate(s) removed, 20 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 14 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 4 1 208.4025 -0.01058500 0.960 NA 1238 1421 10377.83
## 2: 6 1 235.4525 -0.01194145 0.967 NA 2041 2224 11458.26
## 3: 11 1 272.4685 -0.01230098 0.971 NA 4049 4232 14157.94
## 4: 16 1 309.5480 -0.01251044 0.969 NA 6058 6240 16858.44
## 5: 17 1 302.2962 -0.01170419 0.962 NA 6459 6642 17397.63
## 6: 18 1 307.6459 -0.01165524 0.975 NA 6861 7044 17938.20
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 10623.82 98.167 95.645 -0.01058500 0.0006579411 -0.01124294 -0.01124294
## 2: 11704.40 98.206 95.283 -0.01194145 0.0006511156 -0.01259256 -0.01259256
## 3: 14404.04 98.053 94.983 -0.01230098 0.0006340621 -0.01293504 -0.01293504
## 4: 17103.25 98.374 95.274 -0.01251044 0.0006170074 -0.01312745 -0.01312745
## 5: 17643.87 98.367 95.414 -0.01170419 0.0006135969 -0.01231778 -0.01231778
## 6: 18184.08 98.209 95.458 -0.01165524 0.0006101833 -0.01226542 -0.01226542
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04565 0.0006442 NA 37 27 1.013253 -0.1192747
## 2: %Air sec 0.04565 0.0006442 NA 37 27 1.013253 -0.1335927
## 3: %Air sec 0.04565 0.0006442 NA 37 27 1.013253 -0.1372260
## 4: %Air sec 0.04565 0.0006442 NA 37 27 1.013253 -0.1392672
## 5: %Air sec 0.04565 0.0006442 NA 37 27 1.013253 -0.1306776
## 6: %Air sec 0.04565 0.0006442 NA 37 27 1.013253 -0.1301220
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -185.1516 NA mgO2/hr/kg -185.1516
## 2: -207.3776 NA mgO2/hr/kg -207.3776
## 3: -213.0177 NA mgO2/hr/kg -213.0177
## 4: -216.1862 NA mgO2/hr/kg -216.1862
## 5: -202.8525 NA mgO2/hr/kg -202.8525
## 6: -201.9901 NA mgO2/hr/kg -201.9901
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 8 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.0006442 | ch1 | Asus | 0.04565 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 208.2848 | 0.1341771 | 0.9688 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 5.73
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 2 3 6 7 8 9 12 13 14 16 17 18 19 20 22 23 24 25 27 29
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.46
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 394.9133 -0.033641682 0.9921725 NA 141 186 8902.27
## 2: NA 2 394.1915 -0.033561022 0.9919980 NA 140 185 8900.93
## 3: NA 3 394.0650 -0.033546450 0.9918181 NA 142 187 8903.62
## 4: NA 4 393.4278 -0.033475846 0.9917155 NA 138 183 8898.27
## 5: NA 5 393.3400 -0.033465911 0.9916955 NA 139 184 8899.60
## ---
## 175: NA 175 184.9121 -0.009832220 0.9208197 NA 5 50 8719.30
## 176: NA 176 181.1501 -0.009401976 0.9276297 NA 4 49 8717.98
## 177: NA 177 177.6003 -0.008995894 0.9374497 NA 3 48 8716.65
## 178: NA 178 174.1427 -0.008600568 0.9321968 NA 2 47 8715.28
## 179: NA 179 171.1426 -0.008257621 0.9200947 NA 1 46 8713.93
## endtime oxy endoxy rate
## 1: 8962.27 95.392 93.420 -0.033641682
## 2: 8960.93 95.413 93.480 -0.033561022
## 3: 8963.62 95.363 93.442 -0.033546450
## 4: 8958.27 95.533 93.564 -0.033475846
## 5: 8959.60 95.507 93.520 -0.033465911
## ---
## 175: 8779.30 99.134 98.452 -0.009832220
## 176: 8777.98 99.148 98.479 -0.009401976
## 177: 8776.65 99.097 98.562 -0.008995894
## 178: 8775.28 99.084 98.621 -0.008600568
## 179: 8773.93 99.080 98.646 -0.008257621
##
## Regressions : 179 | Results : 179 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 179 adjusted rate(s):
## Rate : -0.03364168
## Adjustment : 0.000683435
## Adjusted Rate : -0.03432512
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 7 rate(s) removed, 172 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 171 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 394.9133 -0.03364168 0.9921725 NA 141 186 8902.27
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 8962.27 95.392 93.42 -0.03364168 0.000683435 -0.03432512 -0.03432512
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04565 0.0006442 NA 37 27 1.013253 -0.3641501
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -565.275 NA mgO2/hr/kg -565.275
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 116 | 8 | CVLA102 | CVLA466 | Vlassof Cay | 320 | 0.0006442 | ch1 | Asus | 0.04565 | 2023-06-07 | 2024-06-13 | good/good | 37 | 27 | 208.2848 | 0.1341771 | 0.9688 | 565.275 | 0.3641501 | 0.9921725 | 356.9901 | 0.229973 | is this max? | |
| ### Expor | ting data |
## Rows: 52 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.